﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TruthTree2.PC.Logic
{
    public class Conditional : Sentence
    {
        public override int SortValue { get { return 2; } }
        public override bool Decomposable { get { return true; } }

        internal Sentence antecedent, consequent;

        public Conditional(Sentence a, Sentence c)
        {
            antecedent = a;
            consequent = c;
        }

        public override Sentence Copy()
        {
            return new Conditional(antecedent.Copy(), consequent.Copy());
        }

        public override Decomposition GetDecomposition()
        {
            Decomposition decomp = new Decomposition();
            decomp.AddToLeft(antecedent.GetNegation());
            decomp.AddToRight(consequent.Copy());

            return decomp;
        }

        public override bool Equal(Sentence o)
        {
            if (o is Conditional)
            {
                Conditional c = (Conditional)o;
                return antecedent.Equal(c.antecedent) && consequent.Equal(c.consequent);
            }

            return false;
        }

        public override string ToString()
        {
            return "(if " + antecedent.ToString() + " " + consequent.ToString() + ")";
        }
    }
}
